package com.inwk.valoepi.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.inwk.valoepi.model.Product;

public class MiscUtils {
	public static boolean isOnlyDigits(String str) {
		for(int i = 0; i < str.length(); i++) {
			if(!Character.isDigit(str.charAt(i))) {
				return false;
			}
		}
		return true;
	}
	
	static List<String> readTextFileToList(String fileName) {
		List<String> lst = new ArrayList<String>();
		BufferedReader br = null;
		try {
			br = new BufferedReader(new FileReader(new File(System.getProperty("user.dir") + fileName)));
			String tmp;
			while((tmp = br.readLine()) != null) {
				lst.add(tmp);
			}
		} catch (FileNotFoundException e) {
			System.out.println("File \"" + fileName + "\" not found!");
		} catch (IOException e) {
			 e.printStackTrace();
		} finally {
			try {
				br.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return lst;
	}
}

